package com.dgut.edu.cn.design.mode.filterchain.filter;

import com.dgut.edu.cn.design.mode.filterchain.dto.PriceCompareResult;
import com.dgut.edu.cn.design.mode.filterchain.dto.RuleFilterResVo;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: hongbin.zheng
 * @create: 2023-08-10 18:49
 **/
@Service
public class MerItemNoRuleFilter implements RuleFilter<PriceCompareResult> {

	@Override
	public RuleFilterResVo doFilter(PriceCompareResult priceCompareResult) throws Exception{
		if (priceCompareResult.getMerItemNo() % 10 == 0) {
			// 如果 尺码 被 10整除，则过滤
			return RuleFilterResVo.fail("若 merItemNo 被 10整除，则过滤，merItemNo = " + priceCompareResult.getMerItemNo(), name());
		}
		return RuleFilterResVo.ok(name());
	}

	@Override
	public String name() {
		return "merItemNoRuleFilter";
	}
}
